package article

import (
	"log"
	"qinnailin.cn/myblog/controllers"
	"qinnailin.cn/myblog/models"
)

type ArticleController struct {
	controllers.BaseController
}

//文章首页
func (this *ArticleController) Index() {
	this.View("index")
}

//查看一篇文章
func (this *ArticleController) Detail() {
	id := this.GetString(":id")
	article := &models.Article{Id: id}
	err := article.Get()
	if err != nil {
		log.Println("文章读取失败：" + err.Error())
		this.Data["Error"] = err.Error()
		this.ViewError()
		return
	}
	article.RNum++
	article.ChangeRNum()
	this.Data["model"] = article
	this.View("detail")
}
